package com.ss.android.common.applog;

import android.accounts.Account;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Looper;
import android.os.Process;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Base64;

import com.bytedance.common.utility.NetworkType;
import com.bytedance.common.utility.Logger;
import com.bytedance.common.utility.b.ThreadPlus;
import com.bytedance.ttnet.a.AppConfig;
import com.ss.android.common.AppContext;
import com.ss.android.common.app.ActivityStackManager;
import com.ss.android.common.util.EventSender;
import com.ss.android.common.util.ToolUtils;
import com.ss.android.f.DeviceRegisterManager;
import com.ss.android.f.a.RegistrationHeaderHelper;
import com.ss.android.newmedia.BaseApplication;
import com.ss.android.newmedia.MediaAppData;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.ref.WeakReference;
import java.net.InetAddress;
import java.net.URI;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

public final class AppLog implements com.ss.android.common.applog.ab.ab$a, com.ss.android.f.a.c, Thread.UncaughtExceptionHandler {
    enum ActionQueueType {
        PAGE_START(0),
        PAGE_END(1),
        EVENT(2),
        IMAGE_SAMPLE(3),
        CONFIG_UPDATE(4),
        API_SAMPLE(5),
        UA_UPDATE(6),
        SAVE_ANR_TAG(7),
        SAVE_DNS_REPORT(8),
        SAVE_MISC_LOG(9),
        DEVICE_ID_UPDATE(10),
        CUSTOMER_HEADER_UPDATE(11),
        UPDATE_GOOGLE_AID(12),
        UPDATE_APP_LANGUAGE(13),
        UPDATE_APP_REGION(14);

        final int nativeInt;

        private ActionQueueType(int i) {
            this.nativeInt = i;
        }
    }


    final static class AppLog$a {
        public final ActionQueueType a;
        public Object b;
        public long c;
        public String d;

        public AppLog$a(ActionQueueType actionQueueType) {
            this.a = actionQueueType;
        }
    }

    final static class ActionReaper extends Thread implements DeviceRegisterManager.a$a {
        private final AppLog b;
        private boolean a;

        public ActionReaper(AppLog arg2) {
            super("ActionReaper");
            this.b = arg2;
            this.a = false;
        }

        public final void a(String arg4, String arg5) {
            AppLog$a v1 = new AppLog$a(ActionQueueType.DEVICE_ID_UPDATE);
            JSONObject v0 = new JSONObject();
            try {
                v0.put("device_id", arg4);
                v0.put("install_id", arg5);
                v1.b = v0;
            } catch (JSONException v0_1) {
                v0_1.printStackTrace();
            }

            this.b.a(v1);
            AppLog.a(this.b, true);
        }

        public final void a(boolean arg3, boolean arg4) {
            if (AppLog.d(this.b)) {
                AppLog.a(this.b, false);
            } else if (arg3) {
                AppLog.b(this.b, arg4);
            }
        }

        public final void run() {
            long v6;
            boolean v1_1;
            Object v3 = null;
            long v8 = 0;
            String v5 = null;
            DeviceRegisterManager.a(((DeviceRegisterManager.a$a) this));
            if (!AppLog.a(this.b)) {
                Logger.w("AppLog", "can not setup LogReaper");
                return;
            }
            AppLog.b(this.b);
            this.b.D();
            while (true) {
                LinkedList v1 = this.b.e;
                synchronized (v1) {
                    if (AppLog.b) {
                        Logger.d("AppLog", "ActionReadper quit");
                        return;
                    }
                    boolean bingo = false;
                    if (!this.b.e.isEmpty()) {
                        bingo = true;
                    } else {
                        try {
                            if (!this.a) {
                                this.b.e.wait();
                            } else {
                                this.b.e.wait(AppLog.c(this.b));
                            }
                        } catch (InterruptedException v0_1) {

                        }
                        if (!AppLog.b) {
                            if (this.b.e.isEmpty()) {
                                v3 = v5;
                            } else {
                                bingo = true;
                            }
                        } else {
                            Logger.d("AppLog", "ActionReadper quit");
                            return;
                        }
                    }

                    if (bingo) {
                        v3 = this.b.e.poll();
                    }
                }
                if (v3 == null) {
                    if (this.a) {
                        this.a = false;
                        this.b.D();
                    }
                    this.b.a(true, false, false);
                    return;
                }

                AppLog v10 = this.b;
                if (!v10.d) {
                } else if (AppLog.b) {
                } else {
                    switch (com.ss.android.common.applog.f.a[((AppLog$a) v3).a.ordinal()]) {
                        case 1: {
                            v10.a(((AppLog$a) v3).c, false);
                            v10.C();
                            break;
                        }
                        case 2: {
                            if ((((AppLog$a) v3).b instanceof r)) {
                                r v0_2 = (com.ss.android.common.applog.r) ((AppLog$a) v3).b;
                                v6 = ((AppLog$a) v3).c;
                                if (v10.i == null) {
                                    Logger.w("AppLog", "no session when onPause: " + v0_2.a);
                                } else if (v10.i.g) {
                                    Logger.w("AppLog", "non-page session when onPause: " + ((r) v0_2).a);
                                } else {
                                    v10.i.i = false;
                                    v10.i.f = v6;
                                    v0_2.c = v10.i.a;
                                    com.ss.android.common.applog.l.a(v10.g).a(((r) v0_2), v6);
                                    try {
                                        JSONObject v1_2 = new JSONObject();
                                        int v0_6 = v10.k.get();
                                        int v3_3 = v10.l.get();
                                        v1_2.put("session_id", v10.i.b);
                                        v1_2.put("cnt_success", v0_6);
                                        v1_2.put("cnt_failure", v3_3);
                                        JSONArray v3_4 = new JSONArray();
                                        Iterator v6_1 = v10.m.iterator();
                                        while (v6_1.hasNext()) {
                                            j v0_21 = (AppLog.j) v6_1.next();
                                            JSONObject v7 = new JSONObject();
                                            v7.put("url", ((j) v0_21).a);
                                            v7.put("networktype", ((j) v0_21).b);
                                            v7.put("time", ((j) v0_21).c);
                                            v7.put("timestamp", ((j) v0_21).d);
                                            v3_4.put(v7);
                                        }

                                        if (v3_4.length() > 0) {
                                            v1_2.put("samples", v3_4);
                                        }

                                        SharedPreferences.Editor v0_7 = v10.g.getSharedPreferences(com.ss.android.f.a.a.a(), 0).edit();
                                        v0_7.putString("stats_value", v1_2.toString());
                                        v0_7.commit();
                                    } catch (Exception v0_5) {
                                    }
                                }
                            }
                            v10.C();
                            break;
                        }
                        case 3: {
                            if (!(((AppLog$a) v3).b instanceof p)) {
                                break;
                            }
                            p v0_2 = (com.ss.android.common.applog.p) ((AppLog$a) v3).b;
                            v10.a(((p) v0_2).g, true);
                            if (v10.i == null) {
                                break;
                            }
                            ((p) v0_2).h = v10.i.a;
                            if (v10.a(((p) v0_2))) {
                                break;
                            }

                            if (com.ss.android.common.applog.l.a(v10.g).a(((p) v0_2)) <= v8) {
                                break;
                            }

                            v10.C();
                            break;
                        }
                        case 4: {
                            label_189:
                            if (!(((AppLog$a) v3).b instanceof j)) {
                                break;
                            }

                            j v0_2 = (AppLog.j) ((AppLog$a) v3).b;
                            if (v10.m.size() >= 5) {
                                v10.m.removeFirst();
                            }

                            v10.m.add(v0_2);
                            break;
                        }
                        case 6: {
                            label_202:
                            if ((((AppLog$a) v3).b instanceof JSONObject)) {
                                String v0_4 = ((AppLog$a) v3).d;
                                try {
                                    v1_1 = Boolean.valueOf(v0_4).booleanValue();
                                } catch (Exception v0_5) {
                                    v0_5.printStackTrace();
                                    v1_1 = false;
                                }

                                JSONObject jo = (JSONObject) ((AppLog$a) v3).b;
                                boolean v3_2 = ((AppLog$a) v3).c == 1 ? true : false;
                                v10.a(((JSONObject) jo), v3_2, v1_1);
                            }

                            AppLog.F();
                            break;
                        }
                        case 7: {
                            if ((((AppLog$a) v3).b instanceof String)) {
                                RegistrationHeaderHelper.a(v10.g, (String) ((AppLog$a) v3).b);
                            }
                            break;
                        }
                        case 9: {
                            if (((AppLog$a) v3).c <= v8) {
                                break;
                            }

                            long v0_3 = ((AppLog$a) v3).c;
                            SharedPreferences.Editor v3_1 = v10.g.getSharedPreferences(com.ss.android.f.a.a.a(), 0).edit();
                            v3_1.putLong("dns_report_time", v0_3);
                            v3_1.commit();
                            break;
                        }
                        case 10: {
                            label_241:
                            if (android.support.design.a.isTextEmpty(((AppLog$a) v3).d)) {
                                break;
                            }

                            if (!(((AppLog$a) v3).b instanceof JSONObject)) {
                                break;
                            }

                            JSONObject jo = (JSONObject) ((AppLog$a) v3).b;
                            String v1_3 = ((AppLog$a) v3).d;
                            try {
                                if (v10.i != null) {
                                    v6 = v10.i.a;
                                } else {
                                    v6 = v8;
                                }
                                if (!v10.d) {
                                    break;
                                }

                                if (v6 <= v8) {
                                    break;
                                }

                                if (android.support.design.a.isTextEmpty(v1_3)) {
                                    break;
                                }

                                if (jo == null) {
                                    break;
                                }

                                com.ss.android.common.applog.l.a(v10.g).a(v6, v1_3, ((JSONObject) jo).toString());
                            } catch (Exception v0_5) {

                            }
                            break;
                        }
                        case 11: {
                            if (!(((AppLog$a) v3).b instanceof Bundle)) {
                                break;
                            }
                            v10.a((Bundle) ((AppLog$a) v3).b);
                            break;
                        }
                        case 12: {
                            if (!(((AppLog$a) v3).b instanceof JSONObject)) {
                                break;
                            }

                            JSONObject jo = (JSONObject) ((AppLog$a) v3).b;
                            if (jo == null) {
                                break;
                            }

                            v1_1 = AppLog.e(v10.h.optString("device_id", v5));
                            String v3_5 = ((JSONObject) jo).optString("device_id", v5);
                            String v6_2 = ((JSONObject) jo).optString("install_id", v5);
                            if (!android.support.design.a.isTextEmpty(v3_5)) {
                                try {
                                    v10.h.put("device_id", v3_5);
                                } catch (JSONException v0_8) {
                                    v0_8.printStackTrace();
                                }
                            }

                            if (!android.support.design.a.isTextEmpty(v6_2)) {
                                try {
                                    v10.h.put("install_id", v6_2);
                                } catch (JSONException v0_8) {
                                    v0_8.printStackTrace();
                                }
                            }

                            if (v10.f != null) {
                                try {
                                    v10.f.a(new JSONObject(v10.h, AppLog.a));
                                } catch (JSONException v0_8) {
                                    v0_8.printStackTrace();
                                }
                            }

                            v10.E();
                            v10.a(true, true, v1_1);
                            break;
                        }
                        case 13: {
                            if (!(((AppLog$a) v3).b instanceof String)) {
                                break;
                            }

                            String v0_21 = (String) ((AppLog$a) v3).b;
                            if (android.support.design.a.isTextEmpty(((String) v0_21))) {
                                break;
                            }

                            if (v10.f == null) {
                                break;
                            }

                            try {
                                if (((String) v0_21).equals(v10.h.optString("google_aid", null))) {
                                    break;
                                }

                                v10.h.put("google_aid", v0_21);
                                if (v10.f != null) {
                                    v10.f.a(new JSONObject(v10.h, AppLog.a));
                                }

                                v10.g.getSharedPreferences(com.ss.android.f.a.a.a(), 0).edit().putString("google_aid", ((String) v0_21)).commit();
                            } catch (Throwable v0) {
                            }

                            break;
                        }
                        case 14: {
                            if (!(((AppLog$a) v3).b instanceof String)) {
                                break;
                            }
                            Object v0_2 = ((AppLog$a) v3).b;
                            if (android.support.design.a.isTextEmpty(((String) v0_2))) {
                                break;
                            }
                            try {
                                if (((String) v0_2).equals(v10.h.optString("app_language", null))) {
                                    break;
                                }
                                v10.h.put("app_language", v0_2);
                                if (v10.f != null) {
                                    v10.f.a(new JSONObject(v10.h, AppLog.a));
                                }
                                v10.g.getSharedPreferences(com.ss.android.f.a.a.a(), 0).edit().putString("app_language", ((String) v0_2)).commit();
                            } catch (Throwable v0) {
                            }
                            break;
                        }
                        case 15: {
                            if (!(((AppLog$a) v3).b instanceof String)) {
                                break;
                            }
                            String v0_2 = (String) ((AppLog$a) v3).b;
                            if (android.support.design.a.isTextEmpty(((String) v0_2))) {
                                break;
                            }
                            try {
                                if (((String) v0_2).equals(v10.h.optString("app_region", null))) {
                                    break;
                                }
                                v10.h.put("app_region", v0_2);
                                if (v10.f != null) {
                                    v10.f.a(new JSONObject(v10.h, AppLog.a));
                                }
                                v10.g.getSharedPreferences(com.ss.android.f.a.a.a(), 0).edit().putString("app_region", ((String) v0_2)).commit();
                            } catch (Throwable v0) {
                            }
                            break;
                        }
                    }
                }
                this.a = true;
                this.b.a(true, false, false);
            }
        }
    }

    public static final class AppLog$c {
        public int a;
        public String b;

        public AppLog$c(String arg1, int arg2) {

            this.b = arg1;
            this.a = arg2;
        }

        public AppLog$c() {

        }
    }

    public interface AppLog$d {
        void aA();

        void az();
    }

    public interface e extends AppLog$d {
        void b(JSONObject arg1);
    }

    public static final class AppLog$f {
        private final BaseApplication a;

        public AppLog$f(BaseApplication arg1) {
            this.a = arg1;
        }

        public static boolean a() {
            boolean v0_1;
            try {
                v0_1 = MediaAppData.provide().K();
            } catch (IllegalStateException v0) {
                v0_1 = false;
            }

            return v0_1;
        }
    }

    public interface g {
        void a(long arg1, String arg2, JSONObject arg3);

        void setSessionId(long arg1);

        void c_();
    }

    final class AppLog$h {
        final String a;
        final int b;
        final int c;
        final int d;
        final int e;
        final int f;
        final int g;

        public AppLog$h(String arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7) {
            this.a = arg1;
            this.b = arg2;
            this.c = arg3;
            this.d = arg4;
            this.e = arg5;
            this.f = arg6;
            this.g = arg7;
        }
    }

    static final class i {
        boolean a;
        long b;
        int c;

        public i() {

            this.a = false;
        }
    }

    static final class j {
        public final String a;
        public final int b;
        public final long c;
        public final long d;

        public j(String arg2, int arg3, long arg4, long arg6) {

            this.a = arg2;
            this.b = arg3;
            this.c = arg4;
            this.d = arg6;
        }
    }

    static final class ImageStatsThread extends ThreadPlus {
        private int a;
        private String b;
        private boolean c;
        private Throwable d;

        public ImageStatsThread(int arg2, String arg3, boolean arg4, Throwable arg5) {
            super("ImageStatsThread");
            this.a = arg2;
            this.b = arg3;
            this.c = arg4;
            this.d = arg5;
        }

        public final void run() {
            int v0_3;
            String v0_1;
            try {
                if (Logger.debug()) {
                    if (this.c) {
                        Logger.v("AppLog", "send image sample: " + this.b);
                    } else {
                        Logger.v("AppLog", "send image error: " + this.b);
                    }
                }

                byte[] v2 = this.b.getBytes("UTF-8");
                v0_1 = this.c ? AppLog.d() : AppLog.e();
                StringBuilder v1 = new StringBuilder(v0_1);
                NetUtil.a(v1, true);
                v0_1 = com.bytedance.common.utility.e.a().a(v1.toString(), v2, false, "text; charset=utf-8", false);
                if (v0_1 == null) {
                    return;
                }

                if (v0_1.length() == 0) {
                    return;
                }

                JSONObject v1_1 = new JSONObject(v0_1);
                if (!AppLog.b(v1_1)) {
                    return;
                }

                v0_1 = v1_1.optString("poke_dns");
                if (v0_1 == null) {
                } else if (v0_1.length() <= 0) {
                } else {
                    try {
                        InetAddress.getByName(v0_1);
                    } catch (Exception v0_2) {
                    }
                }

                label_57:
                if (this.a > 0 && this.a < 100 || this.a > 300) {
                    v0_3 = 1;
                } else {
                    v0_3 = 0;
                }

                if (v0_3 == 0) {
                    return;
                }

                if (this.d == null) {
                    return;
                }

                if (!AppLog.a(v1_1, "send_error_detail")) {
                    return;
                }

                try {
                    v0_1 = this.b;
                    Throwable v1_2 = this.d;
                    StringWriter v2_1 = new StringWriter();
                    PrintWriter v3 = new PrintWriter(((Writer) v2_1));
                    v1_2.printStackTrace(v3);
                    v1_2 = v1_2.getCause();
                    if (v1_2 != null) {
                        v1_2.printStackTrace(v3);
                        v1_2 = v1_2.getCause();
                        if (v1_2 != null) {
                            v1_2.printStackTrace(v3);
                        }
                    }

                    String v1_3 = v2_1.toString();
                    v3.close();
                    JSONObject v2_2 = new JSONObject();
                    v2_2.put("error_info", v0_1);
                    v2_2.put("error_detail", v1_3);
                    com.bytedance.common.utility.e.a().a(AppLog.f(), v2_2.toString().getBytes("UTF-8"), true, "text; charset=utf-8", true);
                } catch (Exception v0_2) {
                }
            } catch (Throwable v0) {

            }
            return;
        }
    }

    final class AppLog$l {
        final String a;
        final double b;

        public AppLog$l(String arg1, double arg2) {
            this.a = arg1;
            this.b = arg2;
        }
    }

    private static String A = "rtlog.snssdk.com";
    private static final SimpleDateFormat B = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
    private static final Object mLock = new Object();
    private static AppLog sInstance;
    private static AtomicLong E = new AtomicLong();
    private static String F = "";
    private static g G;
    private static AppLog$f H;
    private static String I;
    private static String J;
    private static String K;
    private static String L;
    private static boolean M = true;
    private static volatile JSONObject N = null;
    private int O;
    private long P;
    private NetworkType Q;
    private LinkedList R;
    private Thread.UncaughtExceptionHandler mUncaughtExceptionHandler;
    private ANRMonitor mANRMonitor;
    private ab U;
    private int V;
    private AppLog$c W;
    private long X;
    private final JSONObject Y;
    private long Z;
    static final String[] a = new String[]{
            "appkey",
            "udid",
            "openudid",
            "sdk_version",
            "package",
            "channel",
            "display_name",
            "app_version",
            "version_code",
            "timezone",
            "access",
            "os",
            "os_version",
            "os_api",
            "device_model",
            "device_brand",
            "device_manufacturer",
            "language",
            "resolution",
            "display_density",
            "density_dpi",
            "mc",
            "carrier",
            "mcc_mnc",
            "clientudid",
            "install_id",
            "device_id",
            "sig_hash",
            "aid",
            "push_sdk",
            "rom",
            "aliyun_uuid",
            "release_build",
            "update_version_code",
            "manifest_version_code",
            "cpu_abi",
            "build_serial",
            "app_track",
            "serial_number",
            "sim_serial_number",
            "not_request_sender",
            "rom_version",
            "region",
            "tz_name",
            "tz_offset",
            "sim_region",
            "custom",
            "google_aid",
            "app_language",
            "app_region"};
    private static volatile long aA;
    private final ConcurrentHashMap aB;
    private final ConcurrentHashMap aC;
    private final ConcurrentHashMap aD;
    private static final Bundle aE = new Bundle();
    private static boolean aF;
    private static final List aG = new ArrayList();
    private static final Object aH = new Object();
    private static final ThreadLocal aI = new ThreadLocal();
    private volatile long aJ;
    private static WeakReference aK = null;
    private boolean aa;
    private final HashSet ab;
    private String ac;
    private volatile boolean ad;
    private final AtomicBoolean ae;
    private long af;
    private long ag;
    private int ah;
    private List ai;
    private List aj;
    private HashSet ak;
    private Map al;
    private Map am;
    private HashSet an;
    private int ao;
    private Random ap;
    private long aq;
    private volatile long ar;
    private volatile long as;
    private volatile boolean at;
    private static boolean au = false;
    private static AppContext av;
    private static long aw;
    private ac ax;
    private static volatile boolean ay;
    private static volatile boolean az;
    static volatile boolean b = false;
    static com.ss.android.f.a.b c;
    volatile boolean d;
    final LinkedList e;
    volatile v f;
    final Context g;
    final JSONObject h;
    z i;
    public JSONObject timeSync;
    AtomicInteger k;
    AtomicInteger l;
    LinkedList m;
    static int n = 0;
    public static int o;
    private int p;
    private boolean q;
    private static boolean r = true;
    private static boolean s = true;
    private static boolean t = true;
    private static boolean u = true;
    private static boolean v = true;
    private static boolean w = true;
    private static String x = "log.snssdk.com";
    private static String y = "mon.snssdk.com";
    private static String z = "ic.snssdk.com";

    private AppLog(Context arg8) {
        NetworkType v3 = null;
        this.q = false;
        this.O = 1;
        this.P = -1;
        this.Q = v3;
        this.d = false;
        this.e = new LinkedList();
        this.R = new LinkedList();
        this.f = ((v) null);
        this.mUncaughtExceptionHandler = ((Thread.UncaughtExceptionHandler) null);
        this.mANRMonitor = ((ANRMonitor) null);
        this.U = ((ab) null);
        this.V = 0;
        this.X = 0;
        this.Z = 0;
        this.aa = false;
        this.ab = new HashSet();
        this.ac = "";
        this.ad = false;
        this.ae = new AtomicBoolean();
        this.af = 30000;
        this.ag = 0;
        this.ah = 0;
        this.ai = new ArrayList();
        this.aj = new ArrayList();
        this.ak = new HashSet();
        this.al = new HashMap();
        this.am = new HashMap();
        this.an = new HashSet();
        this.ao = 0;
        this.timeSync = ((JSONObject) null);
        this.ap = new Random();
        this.k = new AtomicInteger();
        this.l = new AtomicInteger();
        this.m = new LinkedList();
        this.aq = System.currentTimeMillis();
        this.ar = 0;
        this.as = 0;
        this.at = false;
        this.aB = new ConcurrentHashMap();
        this.aC = new ConcurrentHashMap();
        this.aD = new ConcurrentHashMap();
        this.g = arg8.getApplicationContext();
        this.h = new JSONObject();
        this.Y = new JSONObject();
        AppLog.aw = System.currentTimeMillis();
        this.K();
        CustomChannelHandler.getInstance(arg8).loadAppInstallJsonFromLocal();
        this.d = true;
        new ActionReaper(this).start();
        if (AppLog.M) {
            this.mUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
            if (this.mUncaughtExceptionHandler == this) {
                this.mUncaughtExceptionHandler = ((Thread.UncaughtExceptionHandler) null);
            } else {
                Thread.setDefaultUncaughtExceptionHandler(((Thread.UncaughtExceptionHandler) this));
            }
        }

        this.ax = new ac(this.g);
    }

    public static void A() {
        LinkedList v2;
        AppLog v0_1;
        Object v1 = AppLog.mLock;
        synchronized (v1) {
            if (AppLog.b) {
                return;
            } else {
                AppLog.b = true;
                if (AppLog.sInstance != null) {
                    v0_1 = AppLog.sInstance;
                    v2 = v0_1.e;
                    synchronized (v2) {
                        v0_1.e.clear();
                        v0_1.e.notify();
                    }
                    v0_1.ae.set(true);
                    v2 = v0_1.R;
                    synchronized (v2) {
                        com.ss.android.common.applog.l.a();
                    }
                }
            }
        }
    }

    @Deprecated
    public static void B() {
    }

    final void C() {
        long v0 = System.currentTimeMillis();
        if (v0 - this.aq > 60000) {
            this.aq = v0;
            LinkedList v1 = this.R;
            synchronized (v1) {
                this.R.notify();
            }
        }
        return;
    }

    final void D() {
        int v4 = 2;
        if (this.i != null && !this.i.g) {
            long v0 = System.currentTimeMillis();
            if (!this.i.i && v0 - this.i.f >= this.af) {
                z v0_1 = this.i;
                this.I();
                this.i = null;
                u v1 = new u();
                v1.a = v0_1;
                this.a(((t) v1));
                if (this.U != null) {
                    ab v0_2 = this.U;
                    v0_2.a.removeMessages(v4);
                    v0_2.a.sendEmptyMessageDelayed(v4, 180000);
                }
            }
        }
    }

    final void E() {
        synchronized (this) {
            try {
                AppLog.N = new JSONObject(this.h, AppLog.a);
            } catch (JSONException ex) {
                ex.printStackTrace();
            }
        }
    }

    static void F() {
        if (AppLog.aK != null) {
            Object v0 = AppLog.aK.get();
            if (v0 == null) {
                return;
            }

            try {
                ((AppLog$d) v0).aA();
            } catch (Exception v0_1) {
            }
        }
    }

    public static String G() {
        String v0 = AppLog.sInstance == null ? "" : AppLog.sInstance.ac;
        return v0;
    }

    public static void H() {
    }

    private void I() {
        p v5;
        if (this.i != null) {
            z v2 = this.i;
            l v3 = com.ss.android.common.applog.l.a(this.g);
            int v1 = this.k.getAndSet(0);
            int v4 = this.l.getAndSet(0);
            if (v2 != null && v2.a > 0) {
                if (v1 > 0 || v4 > 0) {
                    v5 = new p();
                    v5.a = "image";
                    v5.b = "stats";
                    v5.d = ((long) v1);
                    v5.e = ((long) v4);
                    v5.g = v2.f;
                    v5.h = v2.a;
                    v3.a(v5);
                }

                if (!this.ad) {
                    this.m.clear();
                }

                Iterator v4_1 = this.m.iterator();
                int v0_1;
                for (v1 = 0; v4_1.hasNext(); v1 = v0_1) {
                    Object v0 = v4_1.next();
                    v5 = new p();
                    v5.a = "image";
                    v5.b = "sample";
                    v5.c = ((j) v0).a;
                    v5.d = ((long) ((j) v0).b);
                    v5.e = ((j) v0).c;
                    v5.g = ((j) v0).d;
                    v5.h = v2.a;
                    v3.a(v5);
                    v0_1 = v1 + 1;
                    if (v0_1 >= 5) {
                        break;
                    }
                }
            }

            this.m.clear();
        }
    }

    private static void J() {
        if (AppLog.aK != null) {
            Object v0 = AppLog.aK.get();
            if (v0 == null) {
                return;
            }

            try {
                ((AppLog$d) v0).az();
            } catch (Exception v0_1) {
            }
        }
    }

    private void K() {
        int v0_3;
        Object v2_1;
        String v0_1;
        long v4;
        SharedPreferences v6;
        long v2;
        try {
            if (AppLog.av != null) {
                this.O = AppLog.av.getVersionCode();
            }

            v2 = System.currentTimeMillis();
            v6 = this.g.getSharedPreferences(com.ss.android.f.a.a.a(), 0);
            this.p = v6.getInt("app_log_last_config_version", 0);
            if (this.p == this.O) {
                v4 = v6.getLong("app_log_last_config_time", 0);
                if (v4 <= v2) {
                    v2 = v4;
                }
                this.ar = v2;
            }
            v0_1 = v6.getString("allow_push_list", null);
            this.ac = v0_1;
            if (v0_1 == null) {

            } else {
                v2_1 = AppLog.mLock;
                synchronized (v2_1) {
                    AppLog.a(this.ab, new JSONArray(v0_1));
                }
            }
            this.ad = v6.getBoolean("allow_old_image_sample", false);
            try {
                v0_1 = v6.getString("real_time_events", null);
                if (android.support.design.a.isTextEmpty(v0_1)) {
                    return;
                }

                JSONArray v2_2 = new JSONArray(v0_1);
                if (v2_2.length() <= 0) {
                    return;
                }

                int v3 = v2_2.length();
                v0_3 = 0;
                while (true) {
                    if (v0_3 >= v3) {
                        return;
                    }

                    String v1 = v2_2.getString(v0_3);
                    if (!android.support.design.a.isTextEmpty(v1)) {
                        this.aD.put(v1, "timely");
                    }
                    ++v0_3;
                    continue;
                }
            } catch (Throwable v0_2) {
                v0_2.printStackTrace();
                return;
            }
        } catch (Exception v0) {
            Logger.w("AppLog", "load allow_push_list exception: " + v0);
        }
    }

    private JSONObject L() {
        String v2;
        JSONObject v0;
        if (this.an != null && !this.an.isEmpty()) {
            v0 = new JSONObject();
            String v1 = "account_facebook";
            try {
                v2 = android.support.design.a.f(this.g, "com.facebook.auth.login");
                if (!TextUtils.isEmpty(((CharSequence) v2))) {
                    v0.put(v1, v2);
                } else {
                }
            } catch (Exception v1_1) {
            }

            v1 = "account_twitter";
            try {
                v2 = android.support.design.a.f(this.g, "com.twitter.android.auth.login");
                if (!TextUtils.isEmpty(((CharSequence) v2))) {
                    v0.put(v1, v2);
                } else {
                }
            } catch (Exception v1_1) {
            }

            v1 = "account_weibo";
            try {
                v2 = android.support.design.a.f(this.g, "com.sina.weibo.account");
                if (!TextUtils.isEmpty(((CharSequence) v2))) {
                    v0.put(v1, v2);
                } else {
                }
            } catch (Exception v1_1) {
            }

            v1 = "account_weixin";
            try {
                v2 = android.support.design.a.f(this.g, "com.tencent.mm.account");
                if (!TextUtils.isEmpty(((CharSequence) v2))) {
                    v0.put(v1, v2);
                } else {
                }
            } catch (Exception v1_1) {
            }

            v1 = "account_renren";
            try {
                v2 = android.support.design.a.f(this.g, "com.renren.renren_account_manager");
                if (!TextUtils.isEmpty(((CharSequence) v2))) {
                    v0.put(v1, v2);
                } else {
                }
            } catch (Exception v1_1) {
            }
        } else {
            v0 = null;
        }

        return v0;
    }

    private boolean M() {
        Iterator v3_3;
        JSONObject v2_4;
        Bundle v2_3;
        Bundle v1_4;
        int v8;
        JSONArray v10;
        int v1_2;
        String v1_1;
        long v4;
        SharedPreferences v3 = null;
        int v0 = 5;
        z v2 = null;
        try {
            DeviceRegisterManager.a(this);
            DeviceRegisterManager.a(AppLog.au);
            DeviceRegisterManager.a(this.g);
            this.d = AppLog.a(this.h, this.g);
            this.i = com.ss.android.common.applog.l.a(this.g).b(0);
            v2 = this.i;
            this.m.clear();
            v3 = this.g.getSharedPreferences(com.ss.android.f.a.a.a(), 0);
            v4 = System.currentTimeMillis();
            this.Z = v3.getLong("send_fingerprint_time", 0);
            if (this.Z >= v4) {
                this.Z = v4 - 86400000;
            }

            v4 = v3.getLong("session_interval", 30000);
            if (v4 >= 15000 && v4 <= 300000) {
                this.af = v4;
            }
            this.ag = v3.getLong("batch_event_interval", 0);
            this.ah = v3.getInt("send_launch_timely", 0);
            v1_1 = v3.getString("image_sampling_ratio", null);
            if (v1_1 == null) {
            } else {
                this.d(new JSONObject(v1_1));
            }
        } catch (Exception v1) {
            Logger.w("AppLog", "load image_stat exception: " + v1);
        }

        try {
            v1_1 = v3.getString("image_error_report", null);
            if (v1_1 == null) {
            } else {
                this.e(new JSONObject(v1_1));
            }
        } catch (Exception v1) {
            Logger.w("AppLog", "load image_error_report exception: " + v1);
        }

        try {
            v1_1 = v3.getString("image_error_codes", null);
            if (v1_1 == null) {
            } else {
                this.ak = AppLog.a(new JSONArray(v1_1));
            }
        } catch (Exception v1) {
            Logger.w("AppLog", "load image_error_codes exception: " + v1);
        }

        try {
            v1_1 = v3.getString("fingerprint_codes", null);
            if (v1_1 == null) {

            } else {
                this.an = AppLog.a(new JSONArray(v1_1));
            }
        } catch (Exception v1) {
            Logger.w("AppLog", "load fingerprint_codes exception: " + v1);
        }
        this.ao = v3.getInt("http_monitor_port", 0);
        if (v2 == null) {

        } else {
            try {
                v1_1 = v3.getString("stats_value", null);
                if (android.support.design.a.isTextEmpty(v1_1)) {

                } else {
                    JSONObject v3_1 = new JSONObject(v1_1);
                    v1_1 = v3_1.optString("session_id", null);
                    if (v1_1 == null) {

                    } else if (!v1_1.equals(v2.b)) {

                    } else {
                        v1_2 = v3_1.optInt("cnt_success", 0);
                        int v2_1 = v3_1.optInt("cnt_failure", 0);
                        if (v1_2 > 0) {
                            this.k.addAndGet(v1_2);
                        }

                        if (v2_1 > 0) {
                            this.l.addAndGet(v2_1);
                        }

                        if (v3_1.isNull("samples")) {

                        } else {
                            v10 = v3_1.getJSONArray("samples");
                            v1_2 = v10.length();
                            if (v1_2 <= v0) {
                                v0 = v1_2;
                            }
                            v8 = 0;
                            while (true) {
                                if (v8 >= v0) {
                                    break;
                                }
                                JSONObject v1_3 = v10.getJSONObject(v8);
                                String v2_2 = v1_3.optString("url", null);
                                int v3_2 = v1_3.getInt("networktype");
                                v4 = v1_3.getLong("time");
                                long v6 = v1_3.getLong("timestamp");
                                if (!android.support.design.a.isTextEmpty(v2_2)) {
                                    this.m.add(new j(v2_2, v3_2, v4, v6));
                                }
                                ++v8;
                                continue;
                            }
                        }
                    }
                }
            } catch (Exception e) {

            }
        }

        try {
            AppLog.J();
            if (this.i != null) {
                Logger.i("AppLog", "start with last session " + this.i.b);
                s v0_2 = new s();
                v0_2.a = this.i.a;
                this.a(((t) v0_2));
            }

            v1_4 = new Bundle();
            v2_3 = AppLog.aE;
            synchronized (v2_3) {
                v1_4.putAll(AppLog.aE);
            }
            if (v1_4.size() <= 0) {

            } else {
                v2_4 = new JSONObject();
                v3_3 = v1_4.keySet().iterator();
                while (v3_3.hasNext()) {
                    Object v0_4 = v3_3.next();
                    v2_4.put(((String) v0_4), v1_4.get(((String) v0_4)));
                }
                this.h.put("custom", v2_4);
            }
        } catch (Throwable v0_3) {
            v0_3.printStackTrace();
        }
        try {
            label_123:
            this.f = new v(this.g, new JSONObject(this.h, AppLog.a), this.R, this.ae, AppLog.G, this.i, this.aB, this.aC);
            this.f.a(this.ag);
            this.f.a = this.ah;
            this.f.start();
            boolean v0_5 = true;
            return v0_5;
        } catch (Exception v0_1) {
            label_159:
            Logger.w("AppLog", "failed to start LogReaper: " + v0_1);
            return false;
        }

    }

    public static String a(String arg1, boolean arg2) {
        return NetUtil.a(arg1, arg2);
    }

    public static void onEvent(String arg11, String arg12, String arg13, long arg14, long arg16, JSONObject arg18) {
        AppLog.onEvent(arg11, arg12, arg13, arg14, arg16, false, arg18);
    }

    public static void a(StringBuilder arg1) {
        NetUtil.a(arg1, false);
    }

    public static void a(long arg2) {
        AppLog.E.set(arg2);
        if (AppLog.sInstance != null) {
            AppLog.J();
        }
    }

    public static void a(Context arg3) {
        AppLog.ay = true;
        if ((arg3 instanceof Activity)) {
            AppLog.au = true;
        }

        AppLog.f(arg3);
        if (!AppLog.aF) {
            AppLog.aF = true;
            new com.ss.android.common.applog.h(com.ss.android.common.applog.g.a(), "handle_cached_events").start();
        }
    }

    public static void a(JSONObject arg4) {
        AppLog v0 = AppLog.sInstance;
        if (v0 == null) {
            return;
        }

        Object v1 = AppLog.mLock;
        synchronized (v1) {
            try {
                v0.h.put("app_track", arg4);
                DeviceRegisterManager.a(v0.g, arg4.toString());
            } catch (JSONException e) {

            }
        }
    }

    public static void a(String arg10, String arg11, String arg12) {
        AppLog.onEvent(arg10, arg11, arg12, 0, 0, false, null);
    }

    public static void a(AppContext arg0) {
        AppLog.av = arg0;
        DeviceRegisterManager.a(arg0);
    }

    public static void a(Context arg0, Account arg1) {
        DeviceRegisterManager.a(arg0, arg1);
    }

    public static void a(com.ss.android.f.a.b arg0) {
        AppLog.c = arg0;
        DeviceRegisterManager.a(arg0);
    }

    public static void a(IAliYunHandler arg0) {
        NetUtil.a(arg0);
    }

    public static void a(String arg1) {
        if (!TextUtils.isEmpty(((CharSequence) arg1))) {
            AppLog.x = arg1;
        }
    }

    public static void a(AppLog$f arg1) {
        AppLog.H = arg1;
        com.ss.android.f.b.aa.a(new com.ss.android.f.b.aa.a$a());
    }

    public static void a(g arg0) {
        AppLog.G = arg0;
    }

    public static void a(e arg1) {
        AppLog.aK = arg1 == null ? null : new WeakReference(arg1);
    }

    public static void a(String arg3, JSONObject arg4) {
        if (!AppLog.b && !android.support.design.a.isTextEmpty(arg3) && arg4 != null && arg4.length() > 0) {
            AppLog v0 = AppLog.sInstance;
            if (v0 == null) {
                return;
            }

            try {
                if (!EventSender.inst().mSenderEnable) {
                } else {
                    JSONObject v1_1 = new JSONObject();
                    v1_1.put("log_type", arg3);
                    v1_1.put("obj", arg4);
                    EventSender.inst().putEvent(v1_1);
                }
            } catch (Exception v1) {
            }
            AppLog$a v1_2 = new AppLog$a(ActionQueueType.SAVE_MISC_LOG);
            v1_2.d = arg3;
            v1_2.b = arg4;
            v0.a(v1_2);
        }
    }

    private static void a(HashSet arg3, JSONArray arg4) throws JSONException {
        if (arg3 != null && arg4 != null) {
            arg3.clear();
            int v1 = arg4.length();
            int v0;
            for (v0 = 0; v0 < v1; ++v0) {
                int v2 = arg4.getInt(v0);
                if (v2 > 0) {
                    arg3.add(Integer.valueOf(v2));
                }
            }
        }
    }

    private static boolean a(JSONObject arg2, Context arg3) {
        try {
            JSONArray v0_1 = new JSONArray();
            if (AppLog.r) {
                v0_1.put(1);
            }

            if (AppLog.s) {
                v0_1.put(2);
            }

            if (AppLog.t) {
                v0_1.put(6);
            }

            if (AppLog.u) {
                v0_1.put(7);
            }

            if (AppLog.v) {
                v0_1.put(8);
            }

            if (AppLog.w) {
                v0_1.put(9);
            }

            arg2.put("push_sdk", v0_1);
        } catch (Exception v0) {
        }

        return RegistrationHeaderHelper.a(arg3, arg2);
    }

    private static HashSet a(JSONArray arg4) throws JSONException {
        HashSet v1 = new HashSet();
        int v2 = arg4.length();
        int v0;
        for (v0 = 0; v0 < v2; ++v0) {
            int v3 = arg4.getInt(v0);
            if (v3 > 0) {
                v1.add(Integer.valueOf(v3));
            }
        }

        return v1;
    }

    private void a(t arg4) {
        this.aq = System.currentTimeMillis();
        LinkedList v1 = this.R;
        synchronized (v1) {
            if (this.R.size() >= 2000) {
                this.R.poll();
            }

            this.R.add(arg4);
            this.R.notify();
        }
    }

    public static int a(int arg4) {
        int v0 = 0;
        AppLog v1 = AppLog.sInstance;
        Object v2 = AppLog.mLock;
        synchronized (v2) {
            if (v1 != null) {
                if (v1.ab.contains(Integer.valueOf(arg4))) {
                    return 1;
                } else {
                    return v0;
                }
            } else {
                return 0;
            }
        }
    }

    private static int a(int arg0, int arg1, int arg2, int arg3) {
        if (arg0 >= arg2) {
            arg1 = arg0 > arg3 ? arg3 : arg0;
        }

        return arg1;
    }

    static String a() {
        String v0 = null;
        if (android.support.design.a.isTextEmpty(v0)) {
            v0 = "http://" + AppLog.x + "/service/2/app_log/";
        }

        return v0;
    }

    @Deprecated
    public static void a(String arg10, int arg11, int arg12) {
        if (!AppLog.b) {
            AppLog v0 = AppLog.sInstance;
            if (v0 != null && (v0.ad)) {
                v0.b("image", "fail", arg10, ((long) arg11), ((long) arg12), true, null);
            }
        }
    }

    @Deprecated
    public static void a(String arg8, int arg9, long arg10) {
        if (!AppLog.b) {
            AppLog v0 = AppLog.sInstance;
            if (v0 != null && (v0.ad)) {
                j v1 = new j(arg8, arg9, arg10, System.currentTimeMillis());
                AppLog$a v2 = new AppLog$a(ActionQueueType.IMAGE_SAMPLE);
                v2.b = v1;
                v0.a(v2);
            }
        }
    }

    final void a(AppLog$a arg4) {
        LinkedList v1 = this.e;
        synchronized (v1) {
            if (AppLog.b) {
                return;
            } else {
                if (this.e.size() >= 2000) {
                    this.e.poll();
                }

                this.e.add(arg4);
                this.e.notify();
                return;
            }
        }
    }

    @Deprecated
    public static void onImageSample(String arg21, long arg22, long arg24, int arg26, String arg27, Throwable arg28) {
        String v2_5;
        String v3_5;
        StringBuilder v9_1;
        int v6_3;
        int v2_4;
        int v3_4;
        i v6_2;
        Map v13;
        int v5 = 0;
        Map v2_3;
        i v3_3;
        Object v3_2;
        Map v6_1 = null;
        long v14;
        int v7_1 = 0;
        Object v2_2;
        List v2_1;
        Object v6;
        NetworkType v12 = null;
        String v9;
        if (AppLog.b) {
            return;
        }

        AppLog v8 = AppLog.sInstance;
        if (v8 == null) {
            return;
        }

        long v10 = System.currentTimeMillis();
        if (arg21 == null) {
            return;
        }

        if (arg21.length() == 0) {
            return;
        }

        try {
            v9 = URI.create(arg21).getHost();
            if (v9 == null) {
                return;
            }

            if (v9.length() == 0) {
                return;
            }

            v12 = android.support.design.a.getNetworkType(v8.g);
            if (arg26 == 11 && v12 == NetworkType.NONE) {
                return;
            }

            v6 = null;
            v2_1 = v8.ai;
            if (v2_1 == null) {
                v2_2 = v6;
            } else if (v12 == null) {
                v2_2 = v6;
            } else if (v12 != NetworkType.NONE) {
                Iterator v7 = v2_1.iterator();
                do {
                    if (v7.hasNext()) {
                        v2_2 = v7.next();
                        if (!((AppLog$l) v2_2).a.equals(v9)) {
                            continue;
                        }
                    } else {
                        v2_2 = v6;
                    }
                    break;
                } while (true);
            } else {
                v2_2 = v6;
            }
            if (v2_2 == null) {
                v7_1 = 0;
            } else if (v8.ap.nextDouble() <= ((AppLog$l) v2_2).b) {
                v7_1 = 1;
            } else {
                v7_1 = 0;
            }
            v2_1 = v8.aj;
            v14 = System.currentTimeMillis() / 1000;
            if (v2_1 != null) {
                Iterator v3 = v2_1.iterator();
                do {
                    if (v3.hasNext()) {
                        v2_2 = v3.next();
                        if (!((AppLog$h) v2_2).a.equals(v9)) {
                            continue;
                        }
                        if (arg26 > 0 && arg26 < 100) {
                            HashSet v3_1 = v8.ak;
                            if (v3_1 == null) {
                                v6_3 = 0;
                                v5 = 0;
                            } else if (v3_1.contains(Integer.valueOf(arg26))) {
                                v6_1 = v8.al;
                                synchronized (v6_1) {
                                    v3_2 = v8.al.get(v9);
                                    if (v3_2 == null) {
                                        v3_3 = new i();
                                        v8.al.put(v9, v3_3);
                                    }
                                    if ((((i) v3_2).a) && v14 - ((i) v3_2).b >= (((long) ((AppLog$h) v2_2).d))) {
                                        ((i) v3_2).c = 0;
                                        ((i) v3_2).a = false;
                                    }
                                    if (!((i) v3_2).a) {
                                        ((i) v3_2).b = v14;
                                        if (v14 - ((i) v3_2).b > (((long) ((AppLog$h) v2_2).b))) {
                                            ((i) v3_2).c = 1;
                                        } else if (((i) v3_2).c < 2147483647) {
                                            ++((i) v3_2).c;
                                        }
                                        if (((i) v3_2).c < ((AppLog$h) v2_2).c) {
                                            v2_3 = null;
                                        } else {
                                            ((i) v3_2).a = true;
                                            v2_3 = null;
                                        }
                                    } else {
                                        v2_3 = null;
                                    }
                                }
                                v5 = 0;
                                v6_1 = v2_3;
                            } else {
                                v6_3 = 0;
                                v5 = 0;
                            }
                        } else if (arg26 <= 300) {
                            v6_3 = 0;
                            v5 = 0;
                        } else {
                            v13 = v8.am;
                            synchronized (v13) {
                                v3_2 = v8.am.get(v9);
                                if (v3_2 == null) {
                                    v3_3 = new i();
                                    v8.am.put(v9, v3_3);
                                    v6_2 = v3_3;
                                } else {
                                    v6_2 = (AppLog.i) v3_2;
                                }
                                if ((v6_2.a) && v14 - v6_2.b >= (((long) ((AppLog$h) v2_2).g))) {
                                    v6_2.c = 0;
                                    v6_2.a = false;
                                }
                                if (!v6_2.a) {
                                    v6_2.b = v14;
                                    if (v14 - v6_2.b > (((long) ((AppLog$h) v2_2).e))) {
                                        v6_2.c = 1;
                                    } else if (v6_2.c < 2147483647) {
                                        ++v6_2.c;
                                    }
                                    v3_4 = 1;
                                    if (v6_2.c < ((AppLog$h) v2_2).f) {
                                        v2_4 = 0;
                                    } else {
                                        v6_2.a = true;
                                        v2_4 = 1;
                                    }
                                } else {
                                    v2_4 = 0;
                                    v3_4 = 0;
                                }
                                v5 = v2_4;
                                v6_3 = v3_4;
                            }
                        }
                    } else {
                        v6_3 = 0;
                        v5 = 0;
                    }
                    break;
                } while (true);
            } else {
                v6_3 = 0;
                v5 = 0;
            }
        } catch (Throwable v2) {

        }
        if (v7_1 == 0 && v6_1 == null) {
            return;
        }

        if (v12 != null) {
            if (v12 == NetworkType.NONE) {
                return;
            }
        }
        v9_1 = new StringBuilder();
        v9_1.append(v10).append("|").append(AppLog.k(arg21)).append("|");
        v9_1.append(arg24).append("|").append(arg22).append("|");
        v9_1.append(arg26).append("|").append(v12.getValue()).append("|");
        if (arg27 != null) {
            v9_1.append(AppLog.k(arg27));
        }

        try {
            if (arg26 == 200) {
                v9_1.append("^^^^");
            } else {
                String v4 = null;
                v2_2 = v8.g.getSystemService(Context.TELEPHONY_SERVICE);
                v3_5 = ((TelephonyManager) v2_2).getNetworkOperatorName();
                v2_5 = ((TelephonyManager) v2_2).getNetworkOperator();
                v9_1.append("^");
                if (v3_5 != null) {
                    v9_1.append(AppLog.k(v3_5));
                }
                v9_1.append("^");
                if (v2_5 != null) {
                    v9_1.append(AppLog.k(v2_5));
                }
                v9_1.append("^0^0");
            }
            v9_1.append("^o1^").append(v5);
            v2_5 = null;
            if (AppLog.sInstance != null) {
                v2_5 = DeviceRegisterManager.a();
            }
            v9_1.append("^");
            if (v2_5 != null) {
                v9_1.append(v2_5);
            }

            if (v6_1 != null && arg26 == 4 && arg28 != null) {
                v9_1.append("^").append(arg28.getClass().getSimpleName());
            }

            v2_5 = v9_1.toString();
            if (v7_1 != 0) {
                new ImageStatsThread(arg26, v2_5, true, arg28).start();
            }
            if (v6_1 == null) {
                return;
            }
            new ImageStatsThread(arg26, v2_5, false, arg28).start();
        } catch (Throwable v2) {
            Logger.w("AppLog", "onImageSample exception: " + v2);
        }
    }

    public static void a(String arg10, String arg11) {
        AppLog.onEvent("umeng", arg10, arg11, 0, 0, false, null);
    }

    public static void onEvent(String arg13, String arg14, String arg15, long arg16, long arg18, boolean arg20, JSONObject arg21) {
        AppLog v0 = AppLog.sInstance;
        if (v0 == null) {
            com.ss.android.common.applog.g v0_1 = com.ss.android.common.applog.g.a();
            synchronized (v0_1.a) {
                if (v0_1.a.size() > 200) {
                    v0_1.a.poll();
                }
                v0_1.a.add(new com.ss.android.common.applog.g.a(arg13, arg14, arg15, arg16, arg18, arg20, arg21));
            }
            Logger.w("AppLog", "null context when onEvent");
        } else {
            if (android.support.design.a.isTextEmpty(arg13)) {
                return;
            }

            if (android.support.design.a.isTextEmpty(arg14)) {
                return;
            }

            if (v0 == null) {
                return;
            }

            v0.b(arg13, arg14, arg15, arg16, arg18, arg20, arg21);
        }
    }

    public static void a(Map arg3) {
        AppLog v0 = null;
        Object v1 = AppLog.mLock;
        synchronized (v1) {
            if (!AppLog.b) {
                v0 = AppLog.sInstance;
            }
            if (v0 != null) {
                DeviceRegisterManager.a(arg3);
                long v0_2 = AppLog.E.get();
                String v0_3 = String.valueOf(v0_2);
                if (v0_3 != null) {
                    arg3.put("user_id", v0_3);
                }
            }
        }
    }

    static boolean a(AppLog arg1) {
        return arg1.M();
    }

    static boolean a(AppLog arg1, String arg2) {
        return arg1.l(arg2);
    }

    static boolean a(AppLog arg0, boolean arg1) {
        arg0.q = arg1;
        return arg1;
    }

    static boolean a(JSONObject arg1, String arg2) {
        return AppLog.b(arg1, arg2);
    }

    @SuppressLint("MissingPermission")
    final void a(boolean arg17, boolean arg18, boolean arg19) {
        CustomChannelHandler v2_8;
        boolean v3_3;
        JSONObject v3_2;
        String v6_1;
        String v2_6;
        Object v3_1 = null;
        Object v2_4;
        JSONObject v5_1;
        String v3;
        JSONObject v2_3;
        int v4_2;
        if (this.at) {
            return;
        }

        if (NetUtil.a(this.h.optString("device_id", null))) {
            return;
        }

        if (android.support.design.a.isTextEmpty(this.h.optString("install_id", null))) {
            return;
        }

        long v8 = System.currentTimeMillis();
        long v6 = 21600000;
        long v4 = 60000;
        int v2 = this.p == this.O ? 1 : 0;
        if (!AppLog.au && this.X < 0 && v2 != 0) {
            v6 = 43200000;
        }

        long v2_1 = v2 != 0 ? 180000 : v4;
        if (this.an == null || !this.an.contains(Integer.valueOf(6)) || this.ax == null) {
            v4_2 = 0;
        } else {
            ac v4_1 = this.ax;
            if (v4_1.a != null) {
                long v10 = System.currentTimeMillis();
                if (v10 - v4_1.c < 1800000) {
                    v4_2 = 0;
                } else if (android.support.design.a.isWifi(v4_1.a)) {
                    String v5 = v4_1.a();
                    if (TextUtils.isEmpty(((CharSequence) v5))) {
                        v4_2 = 0;
                    } else if (!v5.equals(v4_1.b)) {
                        v4_1.d = true;
                        v4_1.e = v5;
                        v4_1.f = v10;
                        v4_2 = 1;
                    } else {
                        v4_2 = 0;
                    }
                } else {
                    v4_2 = 0;
                }
            } else {
                v4_2 = 0;
            }

            if (v4_2 == 0) {
                v4_2 = 0;
            } else {
                v4_2 = 1;
            }
        }

        if (v4_2 == 0) {
            if (!arg18) {
                if (v8 - this.ar < v6) {
                    return;
                } else if (v8 - this.as < v2_1) {
                    Logger.d("AppLog", "next query time : " + DateFormat.getDateTimeInstance().format(new Date(v2_1 + this.as)));
                    return;
                }
            } else if (this.as > this.ar) {
                if (v8 - this.as >= v2_1) {

                } else {
                    return;
                }
            }
        }

        boolean bingo = false;
        Object v4_3 = null;
        HashSet v4_4 = null;
        try {
            if (!android.support.design.a.isNetworkAvailable(this.g)) {
                return;
            }

            this.as = v8;
            this.at = true;
            v2_3 = new JSONObject(this.h, AppLog.a);
            v3 = RegistrationHeaderHelper.b(this.g);
            if (!android.support.design.a.isTextEmpty(v3)) {
                v2_3.put("user_agent", v3);
            }

            v5_1 = new JSONObject();
            v5_1.put("magic_tag", "ss_app_log");
            v5_1.put("header", v2_3);
            v5_1.put("_gen_time", System.currentTimeMillis());
            v2_4 = null;

            if (v8 - this.Z <= 43200000 && v4_2 == 0) {
                v4_3 = v2_4;
                bingo = true;
            } else {
                v4_4 = this.an;
                if (v4_4 == null) {
                    v2_3 = this.Y;
                    v2_6 = v2_3.length() == 0 ? null : AppLog.j(v2_3.toString());
                    String v4_5 = v2_6;
                    bingo = true;
                } else if (!v4_4.isEmpty()) {

                } else {
                    v2_3 = this.Y;
                    v2_6 = v2_3.length() == 0 ? null : AppLog.j(v2_3.toString());
                    String v4_5 = v2_6;
                    bingo = true;
                }
            }
        } catch (Exception v2_2) {
            return;
        }
        if (bingo) {

        } else {


            try {
                v3_1 = this.g.getSystemService(Context.TELEPHONY_SERVICE);
            } catch (Exception v2_2) {
            } catch (Throwable v2_5) {

            }
            if (v3_1 == null) {
                v2_3 = this.Y;
                v2_6 = v2_3.length() == 0 ? null : AppLog.j(v2_3.toString());
                String v4_5 = v2_6;
            } else {
                try {
                    v2_6 = "m_phone_number";
                    if (!v4_4.contains(Integer.valueOf(1))) {

                    } else if (!this.Y.isNull(v2_6)) {

                    } else {
                        try {
                            v6_1 = com.bytedance.common.utility.a.b.a(((TelephonyManager) v3_1));
                            if (v6_1 == null) {

                            } else if (v6_1.length() <= 0) {

                            } else {
                                this.Y.put(v2_6, v6_1);
                            }
                        } catch (Throwable v2_5) {
                            try {
                                this.Y.put("no_m_phone", v2_5.getClass().getName());
                            } catch (Exception v2_2) {
                            }
                        }

                        try {
                            v2_6 = ((TelephonyManager) v3_1).getLine1Number();
                            if (v2_6 != null && v2_6.length() > 0) {
                                this.Y.put("raw_phone_number", v2_6);
                            } else {
                                this.Y.put("no_raw_phone", "empty");
                            }
                        } catch (Throwable v2_5) {
                            try {
                                this.Y.put("no_raw_phone", v2_5.getClass().getName());
                            } catch (Exception v2_2) {

                            }
                        }
                    }
                } catch (Exception v2_2) {
                    return;
                }

                try {
                    v2_6 = "sim_serial";
                    if (!v4_4.contains(Integer.valueOf(2))) {

                    } else if (!this.Y.isNull(v2_6)) {

                    } else {

                        try {
                            v6_1 = ((TelephonyManager) v3_1).getSimSerialNumber();
                            if (v6_1 == null) {

                            } else if (v6_1.length() <= 0) {

                            } else if (v6_1.length() >= 30) {

                            } else {
                                this.Y.put(v2_6, v6_1);
                            }
                        } catch (Throwable v2_5) {
                        }
                    }

                    v2_6 = "subscribe_id";
                    if (!v4_4.contains(Integer.valueOf(3))) {

                    } else if (!this.Y.isNull(v2_6)) {

                    } else {
                        try {
                            v6_1 = ((TelephonyManager) v3_1).getSubscriberId();
                            if (v6_1 == null) {

                            } else if (v6_1.length() <= 0) {

                            } else if (v6_1.length() >= 30) {

                            } else {
                                this.Y.put(v2_6, v6_1);
                            }
                        } catch (Throwable v2_5) {
                        }
                    }
                    v2_6 = "sim_op";
                    if (!v4_4.contains(Integer.valueOf(4))) {

                    } else if (!this.Y.isNull(v2_6)) {

                    } else {
                        try {
                            v6_1 = ((TelephonyManager) v3_1).getSimOperator();
                            if (v6_1 == null) {

                            } else if (v6_1.length() <= 0) {

                            } else if (v6_1.length() >= 30) {

                            } else {
                                this.Y.put(v2_6, v6_1);
                            }
                        } catch (Throwable v2_5) {
                        }
                    }
                    v2_6 = "net_op";
                    if (!v4_4.contains(Integer.valueOf(4))) {

                    } else if (!this.Y.isNull(v2_6)) {

                    } else {
                        try {
                            v6_1 = ((TelephonyManager) v3_1).getNetworkOperator();
                            if (v6_1 == null) {

                            } else if (v6_1.length() <= 0) {

                            } else if (v6_1.length() >= 30) {

                            } else {
                                this.Y.put(v2_6, v6_1);
                            }
                        } catch (Throwable v2_5) {
                        }
                    }

                    v2_6 = "phone_type";
                    if (!v4_4.contains(Integer.valueOf(4))) {

                    } else if (!this.Y.isNull(v2_6)) {

                    } else {
                        this.Y.put(v2_6, ((TelephonyManager) v3_1).getPhoneType());
                    }
                    v2_6 = "net_type";
                    if (!v4_4.contains(Integer.valueOf(4))) {

                    } else if (!this.Y.isNull(v2_6)) {

                    } else {
                        this.Y.put(v2_6, ((TelephonyManager) v3_1).getNetworkType());
                    }

                    v2_6 = "third_part_account";
                    if (!v4_4.contains(Integer.valueOf(5))) {

                    } else if (!this.Y.isNull(v2_6)) {

                    } else {
                        v3_2 = this.L();
                        if (v3_2 == null) {

                        } else {
                            this.Y.put(v2_6, v3_2);
                        }
                    }

                    v3 = "wifi_bssid";
                    if (!v4_4.contains(Integer.valueOf(6))) {

                    } else {
                        CharSequence v2_7 = null;
                        if (this.ax != null) {
                            v2_6 = this.ax.a();
                        }
                        if (TextUtils.isEmpty(v2_7)) {

                        } else {
                            this.Y.put(v3, v2_7);
                        }
                    }
                    v2_3 = this.Y;
                    v2_6 = v2_3.length() == 0 ? null : AppLog.j(v2_3.toString());
                    String v4_5 = v2_6;
                } catch (Exception e) {
                    return;
                }
            }
        }

        try {
            if (v4_3 != null) {
                v3_3 = true;
            } else {
                v3_3 = false;
            }
            if (v4_3 != null) {
                v5_1.put("fingerprint", v4_3);
            }
        } catch (Exception v2_2) {
            return;
        }

        try {
            if (!CustomChannelHandler.a) {

            } else {

                CustomChannelHandler.getInstance(this.g).f = false;
                v2_8 = CustomChannelHandler.getInstance(this.g);
                if (v2_8.mApkCreateTime == -1) {
                    v2 = 0;
                } else if (v2_8.mSystemCreateTime != -1) {
                    v2 = 1;
                } else {
                    v2 = 0;
                }
                if (v2 == 0) {
                    v2_8 = CustomChannelHandler.getInstance(this.g);
                    if (v2_8.mContextRef.get() == null) {

                    } else if (!v2_8.g.compareAndSet(false, true)) {

                    } else {
                        final CustomChannelHandler finalV2_ = v2_8;
                        new ThreadPlus(new Runnable() {

                            public final void run() {
                                try {
                                    CustomChannelHandler.getSystemRecordChannel(finalV2_);
                                    CustomChannelHandler.getSystemCreateTime(finalV2_);
                                    CustomChannelHandler.getApkInfo(finalV2_);
                                    finalV2_.saveAppInstallJson();
                                    CustomChannelHandler.d(finalV2_).set(false);
                                } catch (Throwable v0) {
                                }
                            }
                        }, "get_apk_install_info", true).start();
                    }
                } else {
                    if (CustomChannelHandler.getInstance(this.g).mHasSendAppInfo) {
                        v2_3 = CustomChannelHandler.getInstance(this.g).b();
                    } else {
                        v2_3 = CustomChannelHandler.getInstance(this.g).getAppInstallJson();
                        CustomChannelHandler.getInstance(this.g).f = true;
                    }

                    if (v2_3 == null) {

                    } else {
                        v5_1.put("app_install_info", v2_3);
                    }
                }
            }
        } catch (Exception v2_2) {
        }

        try {
            label_205:
            v2_6 = v5_1.toString();
            if (arg17) {
                new com.ss.android.common.applog.e(this, v2_6, v3_3, arg19).start();
                return;
            }

            this.a(v2_6, v3_3, arg19);
        } catch (Exception v2_2) {

        }
    }

    final void a(long arg10, boolean arg12) {
        int v0;
        l v2 = com.ss.android.common.applog.l.a(this.g);
        if (this.i != null) {
            if (!this.i.i && arg10 - this.i.f >= this.af) {
                v0 = 1;
            } else if ((this.i.g) && !arg12) {
                v0 = 1;
            } else {
                v0 = 0;
            }
        } else {
            v0 = 1;
        }

        if (v0 != 0) {
            this.I();
            z v0_1 = this.i;
            z v3 = new z();
            v3.b = UUID.randomUUID().toString();
            v3.c = arg10;
            v3.f = v3.c;
            v3.d = RegistrationHeaderHelper.c();
            v3.e = RegistrationHeaderHelper.b();
            v3.g = arg12;
            if (!arg12) {
                v3.i = true;
            }

            long v4 = v2.a(v3);
            if (v4 > 0) {
                v3.a = v4;
                this.i = v3;
                Logger.i("AppLog", "start new session " + v3.b);
                g v1 = AppLog.G;
                if (v1 != null) {
                    v1.setSessionId(v4);
                }
            } else {
                this.i = null;
            }

            if (v0_1 == null && this.i == null) {
                return;
            }

            u v1_1 = new u();
            v1_1.a = v0_1;
            if (AppLog.o <= 0) {
                AppLog.o = 6;
            }

            if (this.i != null && !this.i.g) {
                v1_1.b = this.i;
            }

            this.a(((t) v1_1));
        } else if (!arg12) {
            this.i.i = true;
            this.i.f = arg10;
        }
    }

    final void a(Bundle arg5) {
        JSONObject v1;
        JSONObject v0_1;
        if (arg5 != null && (arg5.size() > 0 && this.f != null)) {
            try {
                v0_1 = this.h.optJSONObject("custom");
                if (v0_1 == null) {
                    v1 = new JSONObject();
                } else {
                    v1 = v0_1;
                }
                Iterator v2 = arg5.keySet().iterator();
                while (v2.hasNext()) {
                    Object v0_2 = v2.next();
                    v1.put(((String) v0_2), arg5.get(((String) v0_2)));
                }

                this.h.put("custom", v1);
                if (this.f != null) {
                    this.f.a(new JSONObject(this.h, AppLog.a));
                }

                this.E();
            } catch (Throwable v0) {
            }
        }
    }

    public final void onTrafficWarning(com.ss.android.common.applog.ab.TrafficWarningInfo arg4) {
        Logger.w("AppLog", "onTrafficWarning: " + arg4);
        if (!AppLog.n()) {
            if (this.V == 1) {
                AppLog.A();
                Process.killProcess(Process.myPid());
            } else if (this.V == 2) {
                AppLog.a("traffic_warn", arg4.toString());
            }
        }

        if (this.U != null) {
            this.U.a();
        }
    }

    public final void a(String arg11, String arg12, JSONObject arg13) {
        AppLog.onEvent(arg11, arg12, null, 0, 0, false, arg13);
    }

    final void a(JSONObject arg15, boolean arg16, boolean arg17) {
        int v0_5;
        JSONArray v2_2;
        String v9;
        Object v4;
        JSONArray v3_1;
        if (arg15 == null) {
            return;
        }

        this.ar = System.currentTimeMillis();
        this.p = this.O;
        try {
            long v0_1 = arg15.optLong("server_time");
            if (v0_1 <= 0) {
            } else {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("server_time", v0_1);
                jsonObject.put("local_time", System.currentTimeMillis() / 1000);
                this.timeSync = jsonObject;
                if (this.f == null) {

                } else {
                    this.f.tiemSync = this.timeSync;
                }
            }
        } catch (Exception exception) {
        }
        JSONObject v0_2 = arg15.optJSONObject("config");
        JSONObject v1 = v0_2 == null ? new JSONObject() : v0_2;
        int v2_1 = 0;
        String v0_3 = null;
        try {
            v3_1 = v1.optJSONArray("allow_push_list");
            if (v3_1 == null) {
            } else {
                v4 = AppLog.mLock;
                synchronized (v4) {
                    AppLog.a(this.ab, v3_1);
                }
                v0_3 = v3_1.toString();
                this.ac = v0_3;
            }
        } catch (Throwable v3_2) {
        }

        boolean v3_3 = AppLog.b(v1, "allow_old_image_sample");
        if (v3_3 != this.ad) {
            this.ad = v3_3;
            v2_1 = 1;
        }

        long v4_1 = v1.optLong("session_interval", 0);
        int v3_4 = 0;
        if (v4_1 >= 15 && v4_1 <= 300) {
            v4_1 *= 1000;
            if (v4_1 != this.af) {
                this.af = v4_1;
                v3_4 = 1;
            }
        }

        v4_1 = v1.optLong("batch_event_interval", 0) * 1000;
        if (v4_1 != this.ag) {
            this.ag = v4_1;
            v3_4 = 1;
            if (this.f != null) {
                this.f.a(v4_1);
            }
        }

        int v4_2 = v1.optInt("send_launch_timely");
        if (v4_2 != this.ah) {
            this.ah = v4_2;
            v3_4 = 1;
            if (this.f != null) {
                this.f.a = this.ah;
            }
        }

        String v4_3 = null;
        try {
            JSONObject v5_1 = v1.optJSONObject("image_sampling_ratio");
            if (v5_1 == null) {

            } else if (!this.d(v5_1)) {

            } else {
                v4_3 = v5_1.toString();
            }
        } catch (Exception v5) {

        }

        String v5_2 = null;
        try {
            JSONObject v6_1 = v1.optJSONObject("image_error_report");
            if (v6_1 == null) {

            } else {
                this.e(v6_1);
                v5_2 = v6_1.toString();
            }
        } catch (Exception v6) {
        }

        String v6_2 = null;
        try {
            JSONArray v7_1 = v1.optJSONArray("image_error_codes");
            if (v7_1 == null) {

            } else {
                this.ak = AppLog.a(v7_1);
                v6_2 = v7_1.toString();
            }
        } catch (Exception v7) {

        }

        String v7_2 = null;
        try {
            JSONArray v8_1 = v1.optJSONArray("fingerprint_codes");
            if (v8_1 != null) {
                this.an = AppLog.a(v8_1);
                v7_2 = v8_1.toString();
            }
            v9 = v7_2;
        } catch (Exception v8) {
            v9 = v7_2;
        }
        int v7_3 = 0;
        if (arg16) {
            this.Z = System.currentTimeMillis();
            v7_3 = 1;
        }

        int v8_2 = 0;
        int v10 = v1.optInt("http_monitor_port");
        if (v10 > 0 && v10 != this.ao) {
            this.ao = v10;
            v8_2 = 1;
        }

        SharedPreferences.Editor v10_1 = this.g.getSharedPreferences(com.ss.android.f.a.a.a(), 0).edit();
        if (v3_4 != 0) {
            v10_1.putLong("session_interval", this.af);
            v10_1.putLong("batch_event_interval", this.ag);
            v10_1.putInt("send_launch_timely", this.ah);
        }

        if (v4_3 != null) {
            v10_1.putString("image_sampling_ratio", v4_3);
        }

        if (v5_2 != null) {
            v10_1.putString("image_error_report", v5_2);
        }

        if (v6_2 != null) {
            v10_1.putString("image_error_codes", v6_2);
        }

        if (v9 != null) {
            v10_1.putString("fingerprint_codes", v9);
        }

        if (v0_3 != null) {
            v10_1.putString("allow_push_list", v0_3);
        }

        if (v2_1 != 0) {
            v10_1.putBoolean("allow_old_image_sample", this.ad);
        }

        if (v7_3 != 0) {
            v10_1.putLong("send_fingerprint_time", this.Z);
        }

        if (v8_2 != 0) {
            v10_1.putInt("http_monitor_port", this.ao);
        }

        v10_1.putLong("app_log_last_config_time", this.ar);
        v10_1.putInt("app_log_last_config_version", this.p);
        try {
            v2_2 = v1.optJSONArray("real_time_events");
            this.aD.clear();
            if (v2_2 != null && v2_2.length() > 0) {
                v3_4 = v2_2.length();
                v0_5 = 0;
                while (true) {
                    if (v0_5 < v3_4) {
                        v4_3 = v2_2.getString(v0_5);
                        if (!android.support.design.a.isTextEmpty(v4_3)) {
                            this.aD.put(v4_3, "timely");
                        }
                        ++v0_5;
                        continue;
                    } else {
                        v10_1.putString("real_time_events", v2_2.toString());
                        break;
                    }
                }
            } else {
                v10_1.remove("real_time_events");
            }
        } catch (Throwable v0_4) {
            v0_4.printStackTrace();
        }
        v10_1.commit();
        if (AppLog.aK != null) {
            Object v0_6 = AppLog.aK.get();
            if (!(v0_6 instanceof e)) {
            } else {
                try {
                    ((e) v0_6).b(v1);
                } catch (Exception v0) {
                }
            }
        }
        AppLog.J();
        if ((CustomChannelHandler.getInstance(this.g).f) && !CustomChannelHandler.getInstance(this.g).mHasSendAppInfo) {
            CustomChannelHandler v0_7 = CustomChannelHandler.getInstance(this.g);
            v0_7.mHasSendAppInfo = true;
            v0_7.saveAppInstallJson();
        }

        if ((arg17) && !this.aa && this.Z <= 0) {
            this.aa = true;
            if (this.an.isEmpty()) {
                return;
            }

            this.a(true, true, false);
        }
    }

    final boolean a(String arg4, boolean arg5, boolean arg6) {
        AppLog.aI.set(Boolean.TRUE);
        boolean v0 = this.b(arg4, arg5, arg6);
        Object v1 = AppLog.aH;
        synchronized (v1) {
            this.at = false;
            try {
                AppLog.aH.notifyAll();
            } catch (Exception v2) {
            }
        }

        AppLog.aI.remove();
        if (!v0) {
            AppLog.F();
        }
        return v0;
    }

    final boolean a(p arg11) {
        boolean v0 = true;
        try {
            long v2 = System.currentTimeMillis();
            if (arg11 == null || (arg11.k) || v2 - this.aJ < 900000) {
                return false;
            }

            if (!"event_v3".equalsIgnoreCase(arg11.a)) {
                return false;
            }

            if (this.aD.size() <= 0) {
                return false;
            }

            if (android.support.design.a.isTextEmpty(arg11.b)) {
                return false;
            }

            if (!this.aD.containsKey(arg11.b)) {
                return false;
            }

            if (android.support.design.a.isTextEmpty(arg11.i)) {
                return false;
            }

            JSONObject v2_1 = new JSONObject(arg11.i);
            if (v2_1.optInt("_event_v3", 0) != 1) {
                return false;
            }

            JSONObject v3 = new JSONObject();
            JSONObject v4 = new JSONObject();
            if (v2_1.has("nt")) {
                v4.put("nt", v2_1.optInt("nt"));
            }

            if (arg11.f > 0) {
                v4.put("user_id", arg11.f);
            }

            v2_1.remove("nt");
            v2_1.remove("_event_v3");
            v4.put("event", arg11.b);
            v4.put("params", v2_1);
            v4.put("session_id", arg11.h);
            v4.put("datetime", AppLog.b(arg11.g));
            JSONArray v2_2 = new JSONArray();
            v2_2.put(v4);
            v3.put("event_v3", v2_2);
            if (this.timeSync != null) {
                v3.put("time_sync", this.timeSync);
            }

            v3.put("magic_tag", "ss_app_log");
            v3.put("header", this.h);
            v3.put("_gen_time", System.currentTimeMillis());
            new com.ss.android.common.applog.d(this, v3.toString(), arg11).start();
            return v0;
        } catch (Throwable v0_1) {
        }

        return false;
    }

    public static void b(int arg0) {
        DeviceRegisterManager.a(arg0);
    }

    public static void b(String arg1) {
        if (!TextUtils.isEmpty(((CharSequence) arg1))) {
            AppLog.y = arg1;
        }
    }

    public static void b(Context arg0) {
        com.ss.android.common.applog.v.a(arg0);
    }

    public static void b(String arg2, String arg3) {
        AppLog v0 = AppLog.sInstance;
        if (v0 != null && !android.support.design.a.isTextEmpty(arg2) && !android.support.design.a.isTextEmpty(arg3)) {
            try {
                com.ss.android.common.applog.l.a(v0.g).a(arg2, arg3);
            } catch (Exception v0_1) {
            }
        }
    }

    private void b(String arg7, String arg8, String arg9, long arg10, long arg12,
                   boolean arg14, JSONObject arg15) {
        String v0_1;
        if (this.d) {
            try {
                if (!AppLog.s()) {
                } else if ("event_v3".equalsIgnoreCase(arg7)) {
                    if (this.aC.size() <= 0) {
                    } else if (android.support.design.a.isTextEmpty(arg8)) {
                    } else if (!this.aC.containsKey(arg8)) {
                    } else {
                        Logger.d("AppLog", "hit black event v3");
                        return;
                    }
                } else {
                    if (this.aB.size() <= 0) {
                    } else {
                        if (!android.support.design.a.isTextEmpty(arg9)) {
                            v0_1 = arg8 + arg9;
                        } else {
                            v0_1 = arg8;
                        }
                        if (!this.aB.containsKey(v0_1)) {
                        } else {
                            Logger.d("AppLog", "hit black event v1");
                            return;
                        }
                    }
                }
            } catch (Throwable v0) {
            }

            p v1 = new p();
            v1.a = arg7;
            v1.b = arg8;
            v1.c = arg9;
            v1.d = arg10;
            v1.e = arg12;
            long v2 = System.currentTimeMillis();
            if (this.Q == null || v2 - this.P > 3000) {
                this.Q = android.support.design.a.getNetworkType(this.g);
            }

            NetworkType v0_2 = this.Q;
            if (v0_2 != null) {
                if (arg15 == null) {
                    arg15 = new JSONObject();
                }

                try {
                    arg15.put("nt", v0_2.getValue());
                } catch (Exception v0_3) {
                }
            }

            if (arg15 != null) {
                v1.i = arg15.toString();
            }

            v1.f = AppLog.E.get();
            v1.g = System.currentTimeMillis();
            v1.j = arg14;
            v1.k = false;
            if (Logger.debug()) {
                StringBuilder v0_4 = new StringBuilder();
                v0_4.append("onEvent ").append(arg7).append(" ").append(arg8).append(" ").append(arg9);
                if (arg10 != 0 || arg12 != 0 || arg15 != null) {
                    v0_4.append(" ").append(arg10);
                }

                if (arg12 != 0 || arg15 != null) {
                    v0_4.append(" ").append(arg12);
                }

                if (arg15 != null) {
                    v0_4.append(" ").append(arg15);
                }

                Logger.v("AppLog", v0_4.toString());
            }

            try {
                if (!EventSender.inst().mSenderEnable) {
                } else {

                    JSONObject v2_1 = new JSONObject();
                    if (arg15 != null) {
                        Iterator v3 = arg15.keys();
                        while (v3.hasNext()) {
                            Object v0_5 = v3.next();
                            v2_1.put(((String) v0_5), arg15.get(((String) v0_5)));
                        }
                    }

                    v2_1.put("category", arg7);
                    v2_1.put("tag", arg8);
                    if (!android.support.design.a.isTextEmpty(arg9)) {
                        v2_1.put("label", arg9);
                    }

                    if (arg10 != 0) {
                        v2_1.put("value", arg10);
                    }

                    if (arg12 != 0) {
                        v2_1.put("ext_value", arg12);
                    }
                    EventSender.inst().putEvent(v2_1);
                }
            } catch (Exception v0_3) {
            }
            com.ss.android.common.applog.AppLog.AppLog$a v0_6 = new com.ss.android.common.applog.AppLog.AppLog$a(ActionQueueType.EVENT);
            v0_6.b = v1;
            this.a(v0_6);
        }
    }

    private static boolean b(JSONObject arg2, String arg3) {
        boolean v0 = false;
        if (arg2 != null && !arg2.isNull(arg3)) {
            int v1 = arg2.optInt(arg3, -1);
            if (v1 > 0) {
                v0 = true;
            } else if (v1 != 0) {
                v0 = arg2.optBoolean(arg3, false);
            }
        }

        return v0;
    }

    static String b() {
        return "http://" + AppLog.x + "/service/2/app_log_exception/";
    }

    static String b(long arg2) {
        return AppLog.B.format(new Date(arg2));
    }

    static void b(AppLog arg0) {
        arg0.E();
    }

    static void b(AppLog arg2, boolean arg3) {
        arg2.a(false, true, arg3);
    }

    private boolean b(String arg13, boolean arg14, boolean arg15) {
        // Method was not decompiled
        return true;
    }

    static boolean b(JSONObject arg2) {
        return "success".equals(arg2.optString("message"));
    }

    public static void c(int arg3) {
        AppLog v0 = AppLog.sInstance;
        if (v0 != null) {
            v0.V = arg3;
            if (v0.U == null && arg3 > 0) {
                v0.U = new ab(v0.g, v0);
            }
        }
    }

    public static void c(String arg1) {
        if (!TextUtils.isEmpty(((CharSequence) arg1))) {
            AppLog.z = arg1;
            DeviceRegisterManager.a(arg1);
        }
    }

    static long c(AppLog arg2) {
        return arg2.af;
    }

    static String c() {
        return "http://" + AppLog.y + "/monitor/collect/";
    }

    public static void onResume(Context arg7) {
        if ((arg7 instanceof Activity)) {
            String v0 = arg7.getClass().getName();
            int v1 = arg7.hashCode();
            if (!TextUtils.isEmpty(((CharSequence) v0))) {
                AppLog.J = v0;
                AppLog.L = AppLog.J + "(" + String.valueOf(System.currentTimeMillis()) + ")";
                com.ss.android.common.applog.AppLog.AppLog$c v2 = new com.ss.android.common.applog.AppLog.AppLog$c(v0, v1);
                AppLog v0_1 = AppLog.f(arg7);
                if (v0_1 != null && (v0_1.d)) {
                    if (v0_1.W != null) {
                        Logger.w("AppLog", "onPause not call on " + v0_1.W.b);
                    }

                    long v4 = System.currentTimeMillis();
                    v0_1.X = v4;
                    v0_1.W = v2;
                    if (Logger.debug()) {
                        Logger.v("AppLog", "onResume " + v2.b);
                    }

                    com.ss.android.common.applog.AppLog.AppLog$a v1_1 =
                            new com.ss.android.common.applog.AppLog.AppLog$a(ActionQueueType.PAGE_START);
                    v1_1.c = v4;
                    v0_1.a(v1_1);
                    if (v0_1.mANRMonitor != null) {
                        v0_1.mANRMonitor.a();
                    }

                    if (v0_1.U == null) {
                    } else {
                        v0_1.U.a();
                    }
                }
                DeviceRegisterManager.d();
            }
        }
    }

    private static void c(JSONObject arg3) {
        List v1;
        ArrayList v0_1;
        try {
            v0_1 = new ArrayList();
            v1 = AppLog.aG;
            synchronized (v1) {
                ((List) v0_1).addAll(AppLog.aG);
            }
            Iterator v1_1 = ((List) v0_1).iterator();
            while (v1_1.hasNext()) {
                if (v1_1.next() == null) {
                    continue;
                }
                arg3.optString("data");
            }
        } catch (Throwable v0) {

        }
    }

    public static void d(String arg0) {
        AppLog.F = arg0;
    }

    private boolean d(JSONObject arg11) throws JSONException {
        boolean v0 = false;
        JSONArray v1 = arg11.names();
        if (v1 != null) {
            int v2 = v1.length();
            ArrayList v3 = new ArrayList();
            int v0_1 = 0;
            while (v0_1 < v2) {
                String v4 = v1.getString(((int) v0_1));
                double v6 = arg11.getDouble(v4);
                if (v6 >= 0 && v6 < 1) {
                    ((List) v3).add(new com.ss.android.common.applog.AppLog.AppLog$l(v4, v6));
                }
                v0_1++;
            }

            this.ai = v3;
            return true;
        }

        return v0;
    }

    static String d() {
        return "http://" + AppLog.z + "/cdn/";
    }

    public static void onPause(Context arg10) {
        if ((arg10 instanceof Activity)) {
            String v0 = arg10.getClass().getName();
            int v1 = arg10.hashCode();
            if (!TextUtils.isEmpty(((CharSequence) v0))) {
                com.ss.android.common.applog.AppLog.AppLog$c v2 = new com.ss.android.common.applog.AppLog.AppLog$c(v0, v1);
                AppLog v1_1 = AppLog.f(arg10);
                if (v1_1 != null && (v1_1.d)) {
                    String v3 = v2.b;
                    long v4 = System.currentTimeMillis();
                    com.ss.android.common.applog.AppLog.AppLog$c v6 = v1_1.W;
                    if (v6 == null || v6 != null && v6.a != v2.a) {
                        v0 = "(null)";
                        if (v6 != null) {
                            v0 = v6.b;
                        }

                        Logger.w("AppLog", "unmatched onPause: " + v3 + " " + v0);
                        v1_1.X = v4 - 1010;
                    }

                    v1_1.W = null;
                    int v0_1 = ((int) ((v4 - v1_1.X) / 1000));
                    if (v0_1 <= 0) {
                        v0_1 = 1;
                    }

                    v1_1.X = v4;
                    if (Logger.debug()) {
                        Logger.v("AppLog", "onPause " + v0_1 + " " + v3);
                    }

                    r v2_1 = new r();
                    v2_1.a = v3;
                    v2_1.b = v0_1;
                    com.ss.android.common.applog.AppLog.AppLog$a v0_2 =
                            new com.ss.android.common.applog.AppLog.AppLog$a(ActionQueueType.PAGE_END);
                    v0_2.b = v2_1;
                    v0_2.c = v4;
                    v1_1.a(v0_2);
                    if (v1_1.mANRMonitor == null) {
                    } else {
                        ANRMonitor v0_3 = v1_1.mANRMonitor;
                        v0_3.c = false;
                        v0_3.i = System.currentTimeMillis();
                    }
                }
                DeviceRegisterManager.c();
            }
        }
    }

    static boolean d(AppLog arg1) {
        return arg1.q;
    }

    public static void e(Context arg4) {
        if ((arg4 instanceof Activity)) {
            AppLog.I = arg4.getClass().getName();
            AppLog.K = AppLog.I + "(" + String.valueOf(System.currentTimeMillis()) + ")";
        }
    }

    private void e(JSONObject arg15) throws JSONException {
        JSONArray v9 = arg15.names();
        int v10 = v9.length();
        ArrayList v11 = new ArrayList();
        int v8;
        for (v8 = 0; v8 < v10; ++v8) {
            String v1 = v9.getString(v8);
            JSONObject v0 = arg15.getJSONObject(v1);
            ((List) v11).add(new com.ss.android.common.applog.AppLog.AppLog$h(
                    v1,
                    AppLog.a(v0.optInt("net_error_interval"), 10, 1, 60),
                    AppLog.a(v0.optInt("net_report_count"), 3, 1, 10),
                    AppLog.a(v0.optInt("net_silent_period"), 60, 60, 86400),
                    AppLog.a(v0.optInt("srv_error_interval"), 10, 1, 60),
                    AppLog.a(v0.optInt("srv_report_count"), 3, 1, 10),
                    AppLog.a(v0.optInt("srv_silent_period"), 300, 60, 86400)));
        }

        this.aj = ((List) v11);
    }

    static String e() {
        return "http://" + AppLog.z + "/cdn_error/";
    }

    public static boolean e(String arg1) {
        return NetUtil.a(arg1);
    }

    public static AppLog f(Context arg4) {
        AppLog v0_1;
        if (!AppLog.ay && (Logger.debug())) {
            throw new RuntimeException("getInstance不能在init之前调用");
        }

        Object v1 = AppLog.mLock;
        synchronized (v1) {
            if (AppLog.b) {
                return null;
            } else {
                if (AppLog.sInstance == null) {
                    AppLog.sInstance = new AppLog(arg4);
                    if (Logger.debug()) {
                        Logger.d("Process", " AppLog = " + AppLog.sInstance.toString() + " pid = " + Process.myPid());
                    }
                }
                return AppLog.sInstance;
            }
        }
    }

    public static void f(String userAgent) {
        AppLog appLog = AppLog.sInstance;
        if (appLog != null) {
            String v1 = RegistrationHeaderHelper.b(AppLog.sInstance.g);
            if (!android.support.design.a.isTextEmpty(userAgent) && !userAgent.equals(v1)) {
                com.ss.android.common.applog.AppLog.AppLog$a v1_1 = new com.ss.android.common.applog.AppLog.AppLog$a(ActionQueueType.UA_UPDATE);
                v1_1.b = userAgent;
                appLog.a(v1_1);
            }
        }
    }

    static String f() {
        return "http://" + AppLog.z + "/cdn_error_detail/";
    }

    public static void g() {
        ++AppLog.n;
    }

    public static void g(String arg0) {
        DeviceRegisterManager.b(arg0);
    }

    public static String g(Context arg1) {
        return DeviceRegisterManager.b(arg1);
    }

    public static void h(String arg0) {
        RegistrationHeaderHelper.a(arg0);
    }

    public static String h() {
        return AppLog.F;
    }

    public static String i() {
        return String.valueOf(AppLog.E.get());
    }

    public static void onEvent(String arg10) {
        AppLog.onEvent("umeng", arg10, null, 0, 0, false, null);
    }

    public static String j(String arg4) {
        if (!TextUtils.isEmpty(((CharSequence) arg4))) {
            try {
                byte[] v1 = arg4.getBytes("UTF-8");
                int v2 = v1.length;
                int v0_1;
                for (v0_1 = 0; v0_1 < v2; ++v0_1) {
                    v1[v0_1] = ((byte) (v1[v0_1] ^ -99));
                }

                String v0_2 = Base64.encodeToString(v1, 10);
                return v0_2;
            } catch (Exception v0) {
            }
        }

        return null;
    }

    public static String j() {
        return null;
    }

    public static String k() {
        String v0 = AppLog.sInstance != null ? DeviceRegisterManager.getClientUDID() : null;
        return v0;
    }

    private static String k(String arg2) {
        if (arg2 != null && arg2.length() != 0) {
            if (arg2.indexOf(92) >= 0) {
                arg2 = arg2.replace("\\", "\\\\");
            }

            if (arg2.indexOf(124) >= 0) {
                arg2 = arg2.replace("|", "\\|");
            }

            if (arg2.indexOf(94) < 0) {
                return arg2;
            }

            arg2 = arg2.replace("^", "\\^");
        }

        return arg2;
    }

    public static String deviceId() {
        return AppLog.sInstance != null ? DeviceRegisterManager.a() : null;
    }

    private boolean l(String r9) {
        try {
            AppLog r8 = this;
            int r0 = 0;
            int r6 = 1;
            int r7 = 0;
            String r1 = "AppLog";
            StringBuilder r2 = new StringBuilder("app_log_config: ");
            r2 = r2.append(r9);
            String r2_1 = r2.toString();
            Logger.d(r1, r2_1);
            byte[] r2_2 = r9.getBytes("UTF-8");
            StringBuilder r0_1 = new StringBuilder("http://");
            String r1_2 = A;
            r0_1 = r0_1.append(r1_2);
            r0_1 = r0_1.append("/service/2/app_log/");
            String r0_2 = r0_1.toString();
            Context r1_3 = r8.g;
            String r0_3 = com.ss.android.usergrowth.b.a(r1_3, r0_2);
            String r1_4 = NetUtil.a(r0_3, true);
            byte[] r0_4 = r2_2.clone();
        } catch (Exception e) {
        }
        return false;
    }

    public static long m() {
        long v0_1;
        AppLog v0 = AppLog.sInstance;
        if (v0 == null) {
            v0_1 = 0;
        } else if (v0.W != null) {
            v0_1 = System.currentTimeMillis();
        } else {
            v0_1 = v0.X;
        }

        return v0_1;
    }

    static boolean n() {
        boolean v0 = false;
        AppLog v1 = AppLog.sInstance;
        if (v1 != null && Looper.myLooper() == Looper.getMainLooper() && v1.W != null) {
            v0 = true;
        }

        return v0;
    }

    public static int o() {
        AppLog v0 = AppLog.sInstance;
        int v0_1 = v0 != null ? v0.ao : 0;
        return v0_1;
    }

    public static String p() {
        return RegistrationHeaderHelper.a();
    }

    public static boolean q() {
        com.ss.android.common.applog.AppLog.AppLog$f v0 = AppLog.H;
        boolean v0_1 = v0 != null ? AppConfig.getInstance(v0.a).n() : true;
        return v0_1;
    }

    static boolean r() {
        return true;
    }

    static boolean s() {
        boolean v0 = AppLog.H != null ? com.ss.android.common.applog.AppLog.AppLog$f.a() : true;
        return v0;
    }

    @Deprecated
    public static void t() {
        if (!AppLog.b) {
            AppLog v0 = AppLog.sInstance;
            if (v0 != null) {
                v0.k.incrementAndGet();
            }
        }
    }

    @Deprecated
    public static void u() {
        if (!AppLog.b) {
            AppLog v0 = AppLog.sInstance;
            if (v0 != null) {
                v0.l.incrementAndGet();
            }
        }
    }

    public final void uncaughtException(Thread arg7, Throwable arg8) {
        v v1 = this.f;
        if (arg8 != null && v1 != null) {
            try {
                JSONObject v2 = com.ss.android.common.applog.i.a(this.g, arg8);
                v2.put("last_create_activity", AppLog.I);
                v2.put("last_resume_activity", AppLog.J);
                v2.put("last_create_activity_time", AppLog.K);
                v2.put("last_resume_activity_time", AppLog.L);
                v2.put("app_start_time", AppLog.aw);
                v2.put("app_start_time_readable",
                        new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss").format(new Date(AppLog.aw)));
                if (AppLog.av != null) {
                    v2.put("crash_version", AppLog.av.getVersion());
                    v2.put("crash_version_code", AppLog.av.getVersionCode());
                    v2.put("crash_update_version_code", AppLog.av.getUpdateVersionCode());
                }

                v2.put("alive_activities", ActivityStackManager.getAliveActivitiesString());
                v2.put("running_task_info", ToolUtils.e(this.g));
                if (AppLog.c != null) {
                    JSONObject v3 = new JSONObject();
                    if (v3.length() > 0) {
                        Iterator v4 = v3.keys();
                        while (v4.hasNext()) {
                            Object v0_1 = v4.next();
                            if (android.support.design.a.isTextEmpty(((String) v0_1))) {
                                continue;
                            }

                            v2.put(((String) v0_1), v3.opt(((String) v0_1)));
                        }
                    }
                }

                v1.b(v2);
                AppLog.c(v2);
            } catch (Exception v0) {
            }
        }

        if (ToolUtils.isMainProcess(this.g)) {
            if (this.mUncaughtExceptionHandler == null) {
                return;
            }

            if (this.mUncaughtExceptionHandler == this) {
                return;
            }

            this.mUncaughtExceptionHandler.uncaughtException(arg7, arg8);
            return;
        }

        try {
            if (Logger.debug()) {
                Logger.d("process", "uncaughtException kill myself");
            }

            Process.killProcess(Process.myPid());
        } catch (Throwable v0_2) {
        }
    }

    public static void v() {
        DeviceRegisterManager.e();
    }

    public static int w() {
        return NetUtil.a();
    }

    public static boolean x() {
        return false;
    }

    public static void y() {
        AppLog v0 = AppLog.sInstance;
        if (v0 != null && v0.mANRMonitor == null && v0.f != null) {
            v0.mANRMonitor = ANRMonitor.a(v0.f);
            if (Looper.myLooper() == Looper.getMainLooper() && v0.W != null) {
                v0.mANRMonitor.a();
            }
        }
    }

    public static void z() {
    }
}

